<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="css/雨点动画.css">
</head>

<body>
    <div class="container">
        <div class="cloud">
            <h2>Data Clouds Rain</h2>
        </div>
    </div>

    <script>
        function randomText() {
            var text = '!@#$%^&*()_+'
            letters = text[Math.floor(Math.random() * text.length)]
            return letters
        }

        function rain() {

            let cloud = document.querySelector('.cloud')
            let e = document.createElement('div')
            e.classList.add('drop')
            cloud.appendChild(e)

            let left = Math.floor(Math.random() * 290)
            let size = Math.random() * 1
            let duration = Math.random() * 1

            e.innerText = randomText()
            e.style.left = left + 'px'
            e.style.fontSize = 0.5 + size + 'em '
            e.style.animationDuration = 1 + duration + 's'

            setTimeout(function () {
                cloud.removeChild(e)
            }, 2000)
        }

        setInterval(function () {
            rain()
        }, 20)
    </script>
</body>

</html>